package com.sky.config;


import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.serializer.StringRedisSerializer;

@Configuration
@Slf4j
public class RedisConfiguration {

    @Bean
    public RedisTemplate<String,Object> redisTemplate (RedisConnectionFactory redisConnectionFactory){
        //创建redisTemplate
        RedisTemplate<String, Object> template = new RedisTemplate<>();
        //加入redis连接工厂
        template.setConnectionFactory(redisConnectionFactory);
        //设置主键序列化器
        template.setKeySerializer(new StringRedisSerializer());
        //设置value序列化器
//        template.setValueSerializer(new StringRedisSerializer());

        return template;
    }









}
